package com.easydisk.file.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.easydisk.constant.FileConstant;
import com.easydisk.file.model.entity.UserFile;
import com.easydisk.file.model.vo.BreadcrumbVO;
import com.easydisk.file.model.vo.FolderTreeVO;
import com.easydisk.file.model.vo.UserFileSearchVO;
import com.easydisk.file.model.vo.UserFileVO;
import com.easydisk.vo.UserFileParam;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 用户文件信息表 服务类
 * </p>
 *
 * @author word
 * @since 2023-09-08
 */
public interface UserFileService extends IService<UserFile> {


    boolean secondUploadFile(Long parentId, String filename, String identifier, Long userId);

    /**
     * 根据文件id获取
     */
    UserFile getById(Long fileId);

    /**
     * 根据文件id列表批量获取
     */
    List<UserFile> getBatchByFileId(List<Long> fileIdList);
    /**
     * 获取文件列表
     */
    List<UserFileVO> getUserFileList(Long parentId, String fileTypes, Long userId);

    /**
     * 获取parentId(不包括parentId)下的文件列表
     */
    List<UserFileVO> getUserFileList(Long parentId, String fileTypes,
                                     Long userId, Integer delFlag);

    /**
     * 获取文件列表
     */
    List<UserFileVO> getUserFileList(List<Long> fileIdList);


    void addFolder(Long parentId, String folderName, Long userId);

    void addUserFile(Long parentId, String filename,
                      FileConstant.FolderFlagEnum isFolder, Integer fileType,
                     Long realFileId, Long userId, String fileSizeDesc);

    void updateFilename(Long fileId, String newFilename, Long userId);


    UserFile getUserFileByIdAndUserId(Long fileId, Long userId);

    void deleteByIds(List<Long> fileIdList, Long aLong);

    String getAllAvailableFileIdByFileIds(String fileIds);

    boolean checkAllUpFileAvailable(List<Long> fileIds);

    boolean isFolder(Long fileId);

    boolean isFolder(UserFile userFile);

    List<FolderTreeVO> getFolderTree(Long userId);

    UserFileVO getUserFileInfo(Long fileId, Long userId);

    UserFileVO getNotParentUserFileInfo(Long fileId, Long userId);

    List<UserFileSearchVO> search(String keyword, String fileTypes, Long userId);

    void copyFiles(String fileIds, Long targetParentId, Long userId);

    void transferFiles(String fileIds, Long targetParentId, Long userId);

    void transferFile(UserFile userFile, Long targetParentId);


    /**
     * 用户模块远程调用
     */
    UserFileParam getUserFileParam(Long fileId, Long userId);

    /**
     * 获取对应文件列表的所有文件以及子文件信息
     */
    List<UserFileVO> getAllUserFileVOList(String fileIds);

    void restoreUserFiles(String fileIds, Long userId);

    int deleteBatchUseFileByFileIdAndUserId(List<Long> fileIdList, Long userId);

    /**
     * 校验是不是该物理文件还在使用
     */
    boolean checkRealFileUsed(Long realFileId);

    List<BreadcrumbVO> getBreadcrumbs(Long fileId, Long userId);

    void preview(Long fileId, HttpServletResponse response, Long userId);
}
